<template>
  <div class="app-container">
    <el-form class="formWidth" :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item label="权益类别" prop="rightsType">
        <el-select v-model="queryParams.rightsType" placeholder="请选择权益类别" clearable size="small">
          <el-option
            v-for="dict in rightsTypeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="申报主题" prop="declareTitle">
        <el-input
          v-model="queryParams.declareTitle"
          placeholder="请输入申报主题"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="申报人姓名" prop="username">
        <el-input
          v-model="queryParams.username"
          placeholder="请输入申报人姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="申报人id" prop="soldierId">-->
<!--        <el-input-->
<!--          v-model="queryParams.soldierId"-->
<!--          placeholder="请输入申报人id"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="身份证号" prop="idCard">
        <el-input
          v-model="queryParams.idCard"
          placeholder="请输入身份证号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出生日期" prop="birthDate">
        <el-date-picker clearable size="small"
          v-model="queryParams.birthDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择出生日期">
        </el-date-picker>
      </el-form-item>
<!--      <el-form-item label="户籍所在地" prop="addressBirth">-->
<!--        <el-input-->
<!--          v-model="queryParams.addressBirth"-->
<!--          placeholder="请输入户籍所在地"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="联系电话" prop="phoneNo">
        <el-input
          v-model="queryParams.phoneNo"
          placeholder="请输入联系电话"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="入伍时间" prop="timeEnter">
        <el-date-picker clearable size="small"
          v-model="queryParams.timeEnter"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择入伍时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="复员时间" prop="timeRecover">
        <el-date-picker clearable size="small"
          v-model="queryParams.timeRecover"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择复员时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="安置地点" prop="arrangePlace">
        <el-input
          v-model="queryParams.arrangePlace"
          placeholder="请输入安置地点"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="附件路径" prop="filePath">-->
<!--        <el-input-->
<!--          v-model="queryParams.filePath"-->
<!--          placeholder="请输入附件路径"-->
<!--          clearable-->
<!--          size="small"-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="流程状态" prop="flowStatus">
        <el-select v-model="queryParams.flowStatus" placeholder="请选择流程状态" clearable size="small">
          <el-option
            v-for="dict in flowStatusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="申报回复" prop="flowReply">
        <el-input
          v-model="queryParams.flowReply"
          placeholder="请输入申报回复"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['comprehensive:declare:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['comprehensive:declare:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['comprehensive:declare:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['comprehensive:declare:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="declareList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="申报人姓名" :show-overflow-tooltip="true" align="center" prop="username" />
      <el-table-column label="权益类别" :show-overflow-tooltip="true" align="center" prop="rightsType" :formatter="rightsTypeFormat" />
      <el-table-column label="申报主题" :show-overflow-tooltip="true" align="center" prop="declareTitle" />
<!--      <el-table-column label="申报人id" :show-overflow-tooltip="true" align="center" prop="soldierId" />-->
<!--      :formatter="idNumberFormat"-->
      <el-table-column label="身份证号" :show-overflow-tooltip="true" align="center" prop="idCard" width="190" :formatter="idNumberFormat" />
<!--      <el-table-column label="出生日期" :show-overflow-tooltip="true" align="center" prop="birthDate" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.birthDate, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="户籍所在地" :show-overflow-tooltip="true" align="center" prop="addressBirth" />-->
      <el-table-column label="联系电话" :show-overflow-tooltip="true" align="center" prop="phoneNo" />
<!--      <el-table-column label="入伍时间" :show-overflow-tooltip="true" align="center" prop="timeEnter" width="180">-->
<!--        <template slot-scope="scope" :show-overflow-tooltip="true">-->
<!--          <span>{{ parseTime(scope.row.timeEnter, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="复员时间" :show-overflow-tooltip="true" align="center" prop="timeRecover" width="180">-->
<!--        <template slot-scope="scope" :show-overflow-tooltip="true">-->
<!--          <span>{{ parseTime(scope.row.timeRecover, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="安置地点" :show-overflow-tooltip="true" align="center" prop="arrangePlace" />-->
<!--      <el-table-column label="附件路径" :show-overflow-tooltip="true" align="center" prop="filePath" />-->
      <el-table-column label="流程状态" :show-overflow-tooltip="true" align="center" prop="flowStatus" :formatter="flowStatusFormat" />
      <el-table-column label="申报回复" :show-overflow-tooltip="true" align="center" prop="flowReply" />
      <el-table-column label="申报内容" :show-overflow-tooltip="true" align="center" prop="declareContent" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="240">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['comprehensive:declare:edit']">
            查看
          </el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleSubmit(scope.row)"
            :disabled="scope.row.flowStatus != 0"
            v-hasPermi="['comprehensive:declare:remove']"
          >提交申报</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleEnd(scope.row)"
            :disabled="!(scope.row.flowStatus > 0 && scope.row.flowStatus < 3)"
            v-hasPermi="['comprehensive:declare:remove']"
          >完结</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 添加或修改退役军人权益维护信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
      <el-form class="formWidth" ref="form" :model="form" :rules="rules" label-width="120px">
        <el-row :gutter="20" >
          <el-col :span="12" >
            <el-form-item label="权益类别" prop="rightsType">
              <el-select v-model="form.rightsType" placeholder="请选择权益类别" >
                <el-option
                  v-for="dict in rightsTypeOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item label="申报主题" prop="declareTitle">
              <el-input v-model="form.declareTitle" placeholder="请输入申报主题" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" >
          <el-col :span="12" >
            <el-form-item label="申报人姓名" prop="username">
              <el-input v-model="form.username" placeholder="请输入申报人姓名" />
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item label="身份证号" prop="idCard">
              <el-input v-model="form.idCard" placeholder="请输入身份证号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" >

          <el-col :span="12" >
            <el-form-item label="户籍所在地" prop="addressBirthId">
              <el-cascader
                v-model="form.addressBirthId"
                :options="options"
                :props="propList"
                @change="handleChange"></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item label="详细地址" prop="addressBirth">
              <el-input v-model="form.addressBirth" placeholder="请输入户籍所在地" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" >
          <el-col :span="12" >
            <el-form-item label="联系电话" prop="phoneNo">
              <el-input v-model="form.phoneNo" placeholder="请输入联系电话" />
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item label="入伍时间" prop="timeEnter">
              <el-date-picker clearable size="small"
                              v-model="form.timeEnter"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="选择入伍时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" >
          <el-col :span="12" >
            <el-form-item label="复员时间" prop="timeRecover">
              <el-date-picker clearable size="small"
                              v-model="form.timeRecover"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="选择复员时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item label="安置地点" prop="arrangePlace">
              <el-input v-model="form.arrangePlace" placeholder="请输入安置地点" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20" >
          <el-col :span="12" >
            <el-form-item label="申报回复" prop="flowReply">
              <el-input  v-model="form.flowReply" />
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item label="流程状态" prop="flowStatus">
              <el-select v-model="form.flowStatus" placeholder="请选择流程状态">
                <el-option
                  v-for="dict in flowStatusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12" >
            <el-form-item label="出生日期" prop="birthDate">
              <el-date-picker clearable size="small"
                              v-model="form.birthDate"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="选择出生日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" >
          <el-col :span="24" >
            <el-form-item label="申报内容">
              <el-input
                type="textarea"
                rows="5"
                placeholder="请输入内容"
                v-model="form.declareContent"
                maxlength="500"
                show-word-limit>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 查看退役军人权益维护信息对话框 -->
    <el-dialog :title="title" :visible.sync="openDetails" width="900px" append-to-body>
      <el-form class="formWidth" ref="form" :model="form" :rules="rules" label-width="120px">
        <el-row :gutter="20" >
          <el-col :span="12" >
            <el-form-item label="权益类别" prop="rightsType">
              <el-select v-model="form.rightsType" placeholder="" :disabled="true">
                <el-option
                  v-for="dict in rightsTypeOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item label="申报主题" prop="declareTitle">
              <el-input v-model="form.declareTitle" placeholder=""  :disabled="true"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" >
          <el-col :span="12" >
            <el-form-item label="申报人姓名" prop="username">
              <el-input v-model="form.username" placeholder="" :disabled="true"/>
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item label="身份证号" prop="idCard">
              <el-input v-model="form.idCard" placeholder="" :disabled="true"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" >

          <el-col :span="12" >
            <el-form-item label="户籍所在地" prop="addressBirthId">
              <el-cascader
                v-model="form.addressBirthId"
                :options="options"
                :props="propList"
                :disabled="true"
                @change="handleChange"></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item label="详细地址" prop="addressBirth">
              <el-input v-model="form.addressBirth" placeholder="" :disabled="true"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" >
          <el-col :span="12" >
            <el-form-item label="联系电话" prop="phoneNo">
              <el-input v-model="form.phoneNo" placeholder="" :disabled="true"/>
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item label="入伍时间" prop="timeEnter">
              <el-date-picker clearable size="small"
                              v-model="form.timeEnter"
                              type="date"
                              :disabled="true"
                              value-format="yyyy-MM-dd"
                              placeholder="">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" >
          <el-col :span="12" >
            <el-form-item label="复员时间" prop="timeRecover">
              <el-date-picker clearable size="small"
                              v-model="form.timeRecover"
                              type="date"
                              :disabled="true"
                              value-format="yyyy-MM-dd"
                              placeholder="">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item label="安置地点" prop="arrangePlace">
              <el-input v-model="form.arrangePlace" placeholder="" :disabled="true"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20" >
          <el-col :span="12" >
            <el-form-item label="申报回复" prop="flowReply">
              <el-input  v-model="form.flowReply" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item label="流程状态" prop="flowStatus">
              <el-select v-model="form.flowStatus" placeholder="" :disabled="true">
                <el-option
                  v-for="dict in flowStatusOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12" >
            <el-form-item label="出生日期" prop="birthDate" >
              <el-date-picker clearable size="small"
                              v-model="form.birthDate"
                              type="date"
                              :disabled="true"
                              value-format="yyyy-MM-dd"
                              placeholder="">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" >
          <el-col :span="24" >
            <el-form-item label="申报内容">
              <el-input
                type="textarea"
                rows="5"
                :disabled="true"
                placeholder=""
                v-model="form.declareContent"
                maxlength="500"
                show-word-limit>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="openDetails = !openDetails">确 定</el-button>
<!--        <el-button @click="cancel">取 消</el-button>-->
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { listDeclare, getDeclare, delDeclare, addDeclare, updateDeclare, exportDeclare,submit,end } from "@/api/comprehensive/declare";
import { cityTree } from '@/api/care/care_retirefm'

export default {
  name: "Declare",
  data() {
    const  validatorIdNumber = (rule,value,callback)=>{
      let reg =/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/;
      if(value && !reg.test(value)){
        callback(new Error('请输入正确的身份证号'))
      }else{
        callback()
      }
    }
    return {
      options:[],
      propList:{
        expandTrigger:"hover",
        value:"id",
        label:"cityName",
        children:"cityChildren"
      },
      openDetails:false,
      canSubmit:true,
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 退役军人权益维护信息表格数据
      declareList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 权益类别字典
      rightsTypeOptions: [],
      // 流程状态字典
      flowStatusOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        rightsType: null,
        declareTitle: null,
        declareContent: null,
        username: null,
        soldierId: null,
        idCard: null,
        birthDate: null,
        addressBirth: null,
        phoneNo: null,
        timeEnter: null,
        timeRecover: null,
        arrangePlace: null,
        filePath: null,
        flowStatus: null,
        flowReply: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        rightsType: [
          { required: true, message: "权益类别不能为空", trigger: "change" }
        ],
        declareTitle: [
          { required: true, message: "申报主题不能为空", trigger: "blur" }
        ],
        idCard: [
          { required: false, message: "身份证号不能为空", trigger: "blur" },
          {
            validator:validatorIdNumber,
            trigger:"change"
          }
        ],
        username: [
          { required: true, message: "申报人姓名不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
    this.getDicts("rights_type").then(response => {
      this.rightsTypeOptions = response.data;
    });
    this.getDicts("flow_status").then(response => {
      this.flowStatusOptions = response.data;
    });
    this.cityTree();
  },
  methods: {
    idNumberFormat(row,column){
      return  row.idCard?row.idCard.replace(/^(.{6})(?:\w+)(.{4})$/, "\$1********\$2"):row.idCard
    },
    // 省市区三级联动
    cityTree(){
      cityTree().then(response =>{
        console.log("city",response)
        this.options = response.data;
      });
    },
    handleChange(){},
    /** 查询退役军人权益维护信息列表 */
    getList() {
      this.loading = true;
      listDeclare(this.queryParams).then(response => {
        this.declareList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 权益类别字典翻译
    rightsTypeFormat(row, column) {
      return this.selectDictLabel(this.rightsTypeOptions, row.rightsType);
    },
    // 流程状态字典翻译
    flowStatusFormat(row, column) {
      return this.selectDictLabel(this.flowStatusOptions, row.flowStatus);
    },
    // idNumberFormat(row,column){
    //   // if(row.idNumber){
    //   //   return  row.idNumber.replace(/^(.{6})(?:\w+)(.{4})$/, "\$1********\$2")
    //   // }
    // },

    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        declareId: null,
        rightsType: null,
        declareTitle: null,
        declareContent: null,
        username: null,
        soldierId: null,
        idCard: null,
        birthDate: null,
        addressBirth: null,
        phoneNo: null,
        timeEnter: null,
        timeRecover: null,
        arrangePlace: null,
        filePath: null,
        flowStatus: null,
        flowReply: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.declareId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.canSubmit = true;
      this.reset();
      this.open = true;
      this.title = "添加退役军人权益维护信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const declareId = row.declareId || this.ids
      getDeclare(declareId).then(response => {
        this.form = response.data;

        var addressBirthId = response.data.addressBirthId;
        let birthIdStr = addressBirthId ? addressBirthId.split(',') : null;
        let birthIdArr = birthIdStr ?birthIdStr.map(item => {
          return Number(item)
        }): null;
        this.$set(this.form , 'addressBirthId',birthIdArr)

        this.title = "修改退役军人权益维护信息";

        if(this.form.flowStatus == 0){
          this.open = true;
          return;
        }
        this.openDetails = true;
      });

    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.addressBirthId = this.form.addressBirthId ? this.form.addressBirthId.join(",") : null;
          if (this.form.declareId != null) {
            updateDeclare(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addDeclare(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const declareIds = row.declareId || this.ids;
      this.$confirm('是否确认删除该项数据?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delDeclare(declareIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有退役军人权益维护信息数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportDeclare(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
    },
    /** 提交申报*/
    handleSubmit(row){
      this.$confirm('是否确认提交申报?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(()=>{
          submit(row.declareId).then(res=>{
            this.getList()
            this.msgSuccess("提交申报成功");
          }).catch(err=>{})
      }).catch(() => {});
    },
    /** 完结*/
    handleEnd(row) {
      this.$confirm('是否确认完结?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(()=>{
        end(row.declareId).then(res=>{
          this.getList()
          this.msgSuccess("操作成功");
        }).catch(err=>{})
      }).catch(() => {});
    }
  }
};
</script>
